import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/home",
    component: () => import("@/views/Home"),
    redirect: "/home/article",
    children: [
      { path: "article", component: () => import("@/views/Home/Article") },
      {
        path: "article/details/:id",
        component: () => import("@/views/Home/Details"),
      },
    ],
  },
  {
    path: "/user",
    component: () => import("@/views/User"),
    redirect: "/user/login",
    children: [
      { path: "login", component: () => import("@/views/User/Login") },
      {
        path: "reguser",
        component: () => import("@/views/User/RegUser"),
      },
    ],
  },
  {
    path: "/",
    redirect: "/home/article",
  },
  {
    path: "*",
    component: () => import("@/views/NotFound"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
